<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>按指定格式输出当前日期和时间</title>
</head>
<body>
<script type="text/javascript">
    function getDate() {
        let today = new Date();
        // console.log(today):  Wed Jul 17 2019 17:48:53 GMT+0800 (中国标准时间)
        let date = today.toLocaleString().replace(/下午/, " ");
        // console.log(today.toLocaleString()):  2019/7/17 下午5:48:53 
        return date;
    }
    document.write(getDate());
    // date: 2019/7/17 5:48:53
</script>
</body>
</html>